/*
 * @Description: 
 * @FilePath: \hksj-vued:\03code\hk-iot\src\api\login\index.ts
 * @Date: 2023-07-27 14:41:24
 * @LastEditTime: 2023-11-17 10:27:27
 */
import axiosRequest from '/@/utils/request';

/**
 * （不建议写成 request.post(xxx)，因为这样 post 时，无法 params 与 data 同时传参）
 *
 * 登录api接口集合
 * @method signIn 用户登录
 * @method signOut 用户退出登录
 * @method getUserInfoByToken 根据token获取用户权限
 * @method verifyPassword 验证用户名和密码
 * @method sendVerifyCode 发送验证码
 */
export function useLoginApi() {
  return {
    signIn: async (params: object) => {
      return await axiosRequest({
        url: '/api/login/doLogin',
        method: 'post',
        data: params,
      });
    },
    signOut: async (params: object) => {
      return await axiosRequest({
        url: '/api/login/doLogout',
        method: 'get',
        data: params,
      });
    },
    getUserInfoByToken: async (params: object) => {
      return await axiosRequest({
        url: '/api/login/getUserInfo',
        method: 'get',
        params,
      });
    },
    verifyPassword: async (params: object) => {
      return await axiosRequest({
        url: '/api/login/verifyPassword',
        method: 'POST',
        data: params,
      });
    },
    sendVerifyCode: async (params: object) => {
      return await axiosRequest({
        url: '/api/login/sendVerifyCode',
        method: 'POST',
        data: params,
      });
    },
  };
}
